package com.java.demo.model;

import java.io.*;

/**
 * @auther zhangwj
 * @date 2021/1/5 下午1:53
 */
public class DecoratorPattern2 {

    public static void main(String[] args) throws IOException {
        File file = new File("/Users/zhangwj/Downloads/start.sh");
        InputStream inputStream = new FileInputStream(file);
        FilterInputStream filterInputStream = new LowerCaseInputStream(inputStream);

        int row;
        while ((row = filterInputStream.read()) != -1) {
            System.out.println((char) row);
        }
    }
}


class LowerCaseInputStream extends FilterInputStream {

    LowerCaseInputStream(InputStream is) {
        super(is);
    }

    @Override
    public int read() throws IOException {
        int c = super.read();
        return (c == -1 ? c : Character.toLowerCase(c));
    }
}